package com.chrudgames.stayintouch;


import android.app.Activity;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;
import android.widget.Toast;

public class Communicate extends Activity implements OnClickListener{

	@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.communicate);
    
        TextView mTextView = (TextView) findViewById(R.id.tvIntro);
        mTextView.setText(this.getString(R.string.If_you_are)  + "\n\n" + this.getString(R.string.If_you_like) );
        }
	
	protected void onStart() {
		
		 super.onStart();
		
		
	}    

	public void onClick(View v) {
		
		Intent i = new Intent(Intent.ACTION_SEND);		
		i.setType("message/rfc822");
		
		switch (v.getId()) {
		
			
		case R.id.cmdBug:
		
			PackageInfo pInfo;
			String version="";
									
			try {
				pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
				version = "\n\n\n\n\n" + "Version: " + pInfo.versionName;
			} catch (NameNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			
		    String  ANDROID         =   android.os.Build.VERSION.RELEASE;       //The current development codename, or the string "REL" if this is a release build.
		    //String  BOARD           =   android.os.Build.BOARD;                 //The name of the underlying board, like "goldfish".    
		    //String  BOOTLOADER      =   android.os.Build.BOOTLOADER;            //  The system bootloader version number.
		    String  BRAND           =   "Carrier: " + android.os.Build.BRAND;                 //The brand (e.g., carrier) the software is customized for, if any.
		    //String  CPU_ABI         =   android.os.Build.CPU_ABI;               //The name of the instruction set (CPU type + ABI convention) of native code.
		    //String  CPU_ABI2        =   android.os.Build.CPU_ABI2;              //  The name of the second instruction set (CPU type + ABI convention) of native code.
		    //String  DEVICE          =   android.os.Build.DEVICE;                //  The name of the industrial design.
		    //String  DISPLAY         =   android.os.Build.DISPLAY;               //A build ID string meant for displaying to the user
		    //String  FINGERPRINT     =   android.os.Build.FINGERPRINT;           //A string that uniquely identifies this build.
		    //String  HARDWARE        =   android.os.Build.HARDWARE;              //The name of the hardware (from the kernel command line or /proc).
		    //String  HOST            =   android.os.Build.HOST;  
		    //String  ID              =   android.os.Build.ID;                    //Either a changelist number, or a label like "M4-rc20".
		    String  MANUFACTURER    =   "Maker: " + android.os.Build.MANUFACTURER;          //The manufacturer of the product/hardware.
		    String  MODEL           =   "Model: " + android.os.Build.MODEL; 

		    version = version + "\n" + "Android: " + ANDROID  + "\n" + BRAND + "\n" + MANUFACTURER  + "\n" + MODEL;
			
			i.putExtra(Intent.EXTRA_EMAIL  , new String[]{"Support@ChrudGames.com"});
			i.putExtra(Intent.EXTRA_SUBJECT, this.getString(R.string.Bug));
			i.putExtra(Intent.EXTRA_TEXT   , this.getString(R.string.I_have_the) + version);
			try {
			    startActivity(Intent.createChooser(i, "Send mail..."));
			} catch (android.content.ActivityNotFoundException ex) {
			    Toast.makeText(this, "There are no email clients installed.", Toast.LENGTH_SHORT).show();
			}

	      	break;
	      	
		case R.id.cmdFeature:
			
			i.putExtra(Intent.EXTRA_EMAIL  , new String[]{"Support@ChrudGames.com"});
			i.putExtra(Intent.EXTRA_SUBJECT, this.getString(R.string.Feature_Request));
			i.putExtra(Intent.EXTRA_TEXT   , this.getString(R.string.It_would_be));
			try {
			    startActivity(Intent.createChooser(i, "Send mail..."));
			} catch (android.content.ActivityNotFoundException ex) {
			    Toast.makeText(this, "There are no email clients installed.", Toast.LENGTH_SHORT).show();
			}
			
	      	break;
		
		case R.id.cmdRate:
			
			 String myUrl = "market://details?id=com.chrudgames.stayintouch";
	            Intent im = new Intent(Intent.ACTION_VIEW, Uri.parse(myUrl)) ;
	            startActivity(im);


	      	break;  	
	      	
		case R.id.cmdTell:
			
			String strLink = "<a href='http://market.android.com/details?id=com.chrudgames.stayintouch'>StayInTouch at Google Play</a>";
		
			//i.putExtra(Intent.EXTRA_BCC  , new String[]{"Support@ChrudGames.com"});
			i.putExtra(Intent.EXTRA_SUBJECT, this.getString(R.string.app_name));
			i.putExtra(Intent.EXTRA_TEXT   , this.getString(R.string.I_have_been_using) + "\n\n\n" + strLink );
			try {
			    startActivity(Intent.createChooser(i, "Send mail..."));
			} catch (android.content.ActivityNotFoundException ex) {
			    Toast.makeText(this, "There are no email clients installed.", Toast.LENGTH_SHORT).show();
			}
	      	
	      	break;
		
		}

	 
	    i = null;      
	      
	    }

	  @Override
	    public boolean onCreateOptionsMenu(Menu menu) {
	        MenuInflater inflater = getMenuInflater();
	        inflater.inflate(R.layout.menu, menu);
	        return true;
	    }
	    
	    @Override
	    public boolean onOptionsItemSelected(MenuItem item) {
	        // Handle item selection
	        switch (item.getItemId()) {
	            
	        case R.id.communicate:
	        	Intent i4 = new Intent(this, Communicate.class);

	        	startActivity(i4);
	        	return true;
	      	
	        case R.id.options:
	            	Intent i = new Intent(this, Prefs.class);
	               	startActivity(i);
	    	
	                return true;
	            case R.id.upgrade:
	            	Intent i3 = new Intent(this, Upgrade.class);
	               	startActivity(i3);
	                return true;
	            case R.id.help:
	            	Intent i2 = new Intent(this, Help.class);
	               	startActivity(i2);
	                return true;
	            default:
	                return super.onOptionsItemSelected(item);
	        }
	    }
	
}
